package pattern.behavioral.command.simple;

/**
 * @author: chaoyang.ren  
 * @date:Jun 9, 2017  
 * @time:11:22:35 AM   
 * @email:chaoyang.ren@foxmail.com  
 * @version: 1.0
 */
public class Test {
	public static void main(String[] args) {
		//电器
		Fan fan = new Fan();
		Television tv = new Television();
		Light light = new Light();
		
		//命令
		Command fanOn = new FanOnCommand(fan);
		Command fanOff = new FanOffCommand(fan);
		Command tvOn = new TelevisionOnCommand(tv);
		Command tvOff = new TelevisionOffCommand(tv);
		Command lightOn = new LightOnCommand(light);
		Command lightOff = new LightOffCommand(light);
		
		//在遥控器中设置命令
		RemoteControl control = new RemoteControl();
		control.setCommand(1, fanOn);
		control.setCommand(2, fanOff);
		control.setCommand(3, tvOn);
		control.setCommand(4, tvOff);
		control.setCommand(5, lightOn);
		control.setCommand(6, lightOff);
		
		//点击遥控器
		control.command(1);
		control.command(2);
		control.command(3);
		control.command(4);
		control.command(5);
		control.command(6);
	}
}

